home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
os20
/
cdity
/
yak14a.lha
/
Yak
/
Source
/
help.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-22
|
7KB
|
334 lines
/*
* help.c
*
* Opens help/settings window and handles events.
* For yak.
*
* Martin W. Scott, 12-Sep-92.
*/
#include <exec/types.h>
#include <dos/dosextens.h>
#include <libraries/commodities.h>
#include <intuition/intuition.h>
#include <libraries/gadtools.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/gadtools.h>
#include <proto/graphics.h>
#include <proto/commodities.h>
#include <string.h>
#include "yak.h"
#include "popup.h"
#include "version.h"
#ifndef GTMN_NewLookMenus
#define GTMN_NewLookMenus GT_TagBase+67
#endif
#ifndef WA_NewLookMenus
#define WA_NewLookMenus WA_Dummy+0x30
#endif
#include "popup.c" /* NB!!! compile with NO MULTI-INCLUDES */
/* static protos */
static void __regargs InitGadget(UWORD num, LONG tagtype, LONG tagvalue);
static void InitGadgets(void);
static void __regargs NewPattern(UWORD gdx, UWORD n, struct Gadget *gad);
static UWORD n; /* currently shown hotkey */
/* menu numbers */
#define LOAD 0
#define SAVE 1
#define HIDE 2
#define QUIT 3
/* initialise individual gadget */
static void __regargs
InitGadget(UWORD num, LONG tagtype, LONG tagvalue)
{
GT_SetGadgetAttrs(HelpGadgets[num], HelpWnd, NULL, tagtype, tagvalue, TAG_DONE);
}
/* initialise all gadgets */
static void
InitGadgets()
{
UWORD i;
for (i = 0; i < NUM_TOGGLES; i++)
if (toggles[i].gadid != -1)
InitGadget(toggles[i].gadid,
GTCB_Checked,
toggles[i].pos);
InitGadget(GDX_MBMethod, GTCY_Active, mouseblank);
InitGadget(GDX_hkListView, GTLV_Selected, n);
InitGadget(GDX_KeyStr, GTST_String, (LONG)hk[n].key);
InitGadget(GDX_PopCLIStr, GTST_String, (LONG)PopCommand);
InitGadget(GDX_ScrTONum, GTIN_Number, blanksecs);
InitGadget(GDX_MouseTONum, GTIN_Number, mblanksecs);
InitGadget(GDX_ClickVol, GTIN_Number, click_volume);
InitGadget(GDX_DateFmt, GTST_String, (LONG)DateFormat);
InitGadget(GDX_AutoPat, GTST_String, (LONG)patterns[YP_AUTOSCR_PAT].patstr);
InitGadget(GDX_ClickPat, GTST_String, (LONG)patterns[YP_CLICKSCR_PAT].patstr);
InitGadget(GDX_PopPat, GTST_String, (LONG)patterns[YP_POPWIN_PAT].patstr);
InitGadget(GDX_ClickWinPat, GTST_String, (LONG)patterns[YP_CLICKWIN_PAT].patstr);
}
/* show our help window */
BOOL
ShowWindow()
{
static char title[80];
WBenchToFront();
if (HelpWnd) /* already open... */
{
WindowToFront(HelpWnd);
return TRUE;
}
if (SetupScreen()) /* try to get lock on WB */
return FALSE;
strcpy(title, VERSION_NAME ": HotKey=<");
strcat(title, hk[HK_POPKEY].key);
strcat(title, ">");
HelpWdt = title;
if (!OpenHelpWindow()) /* like the name says... */
{
InitGadgets();
wndsigflag = 1 << HelpWnd->UserPort->mp_SigBit;
return TRUE;
}
CloseDownScreen();
return FALSE;
}
/* hide our help window */
void
HideWindow()
{
if (HelpWnd)
{
CloseHelpWindow();
CloseDownScreen();
wndsigflag = NULL;
HelpWnd = NULL;
}
}
/* handle pattern string-gadget */
static void __regargs
NewPattern(UWORD gdx, UWORD n, struct Gadget *gad)
{
char *newpatstr;
newpatstr = GetString(gad);
if (!InitPattern(newpatstr, n))
{
DisplayBeep(Scr);
InitGadget(gdx, GTST_String, (LONG)patterns[n].patstr);
}
}
/* handle window events */
LONG
HandleIDCMP()
{
struct IntuiMessage *msg;
struct Gadget *gadget;
ULONG class;
UWORD code;
LONG num;
while (msg = GT_GetIMsg(HelpWnd->UserPort))
{
class = msg->Class;
code = msg->Code;
gadget = (struct Gadget *)msg->IAddress;
GT_ReplyIMsg(msg);
switch (class)
{
case CLOSEWINDOW:
HideWindow();
return HELP_OKAY;
case GADGETUP:
case GADGETDOWN:
switch (gadget->GadgetID)
{
case GD_KeyStr:
{ /* set new hotkey-string */
char *newstr;
newstr = GetString(gadget);
if (!AddHotKey(newstr, n))
{
DisplayBeep(Scr);
InitGadget(GDX_KeyStr, GTST_String, (LONG)hk[n].key);
}
}
break;
case GD_hkListView:
n = code;
InitGadget(GDX_KeyStr, GTST_String, (LONG)hk[n].key);
break;
case GD_PopCLIStr:
strcpy(PopCommand, GetString(gadget));
break;
case GD_DateFmt:
strcpy(DateFormat, GetString(gadget));
break;
case GD_AutoPat:
NewPattern(GDX_AutoPat, YP_AUTOSCR_PAT, gadget);
break;
case GD_ClickPat:
NewPattern(GDX_ClickPat, YP_CLICKSCR_PAT, gadget);
break;
case GD_PopPat:
NewPattern(GDX_PopPat, YP_POPWIN_PAT, gadget);
break;
case GD_ClickWinPat:
NewPattern(GDX_ClickWinPat, YP_CLICKWIN_PAT, gadget);
break;
case GD_Hide:
HideWindow();
return HELP_OKAY;
case GD_Quit:
HideWindow();
return HELP_QUIT;
case GD_AutoCheck: /* toggle */
autopoint ^= TRUE;
break;
case GD_AutoPopCheck: /* toggle */
autopop ^= TRUE;
break;
case GD_KeyActCheck: /* toggle */
keyactivate ^= TRUE;
break;
case GD_CTFCheck: /* toggle */
clicktofront ^= TRUE;
break;
case GD_CTBCheck: /* toggle */
clicktoback ^= TRUE;
break;
case GD_ScrCycleCheck: /* toggle */
screencycle ^= TRUE;
break;
case GD_WildStarCheck: /* toggle */
wildstar ^= TRUE;
if (wildstar) WILDSTARON; else WILDSTAROFF;
break;
case GD_ScrActCheck: /* toggle */
scractivate ^= TRUE;
break;
case GD_RMBActCheck: /* toggle */
rmbactivate ^= TRUE;
break;
case GD_ScrTONum:
num = GetNumber(gadget);
if (num >= 0) {
blanksecs = num;
blankcount = blanktimeout = blanksecs*10;
} else {
InitGadget(GDX_ScrTONum, GTIN_Number, blanksecs);
DisplayBeep(HelpWnd->WScreen);
}
break;
case GD_MouseTONum:
num = GetNumber(gadget);
if (num >= 0) {
mblanksecs = num;
mblankcount = mblanktimeout = mblanksecs*10;
} else {
InitGadget(GDX_MouseTONum, GTIN_Number, mblanksecs);
DisplayBeep(HelpWnd->WScreen);
}
break;
case GD_ClickVol:
num = GetNumber(gadget);
if (num >= 0 && num <= 64) {
click_volume = num;
} else {
InitGadget(GDX_ClickVol, GTIN_Number, click_volume);
DisplayBeep(HelpWnd->WScreen);
}
break;
case GD_MBMethod:
mouseblank = code;
mblankcount = mblanktimeout;
break;
} /* switch (gadget->GadgetID) */
break;
case REFRESHWINDOW:
GT_BeginRefresh(HelpWnd);
/* HelpRender();*/
GT_EndRefresh(HelpWnd, TRUE);
break;
case IDCMP_MENUPICK:
while (code != MENUNULL)
{
struct MenuItem *item = ItemAddress(HelpMenus, code);
switch (ITEMNUM(code))
{
case LOAD:
LoadSettings(CONFIG_FILE);
InitGadgets();
break;
case SAVE:
SaveSettings(CONFIG_FILE);
break;
case HIDE:
HideWindow();
return HELP_OKAY;
case QUIT:
HideWindow();
return HELP_QUIT;
}
code = item->NextSelect;
} /* while more menuchoices */
break;
} /* switch (class) */
} /* while more messages */
return HELP_OKAY;
}